#!/usr/bin/python3.5

# -*- coding: utf-8 -*-

#!/usr/bin/python3.5

# -*- coding: utf-8 -*-




class Solution:
    def removeDuplicates(self, nums):
        k=1
        cur =2
        while cur  < len(nums):
            if nums[k-1]!=nums[cur]:
                k+=1
                nums[k]=nums[cur]
                cur+=1
            else:
                cur+=1
        return k+1



if __name__=='__main__':
    # arr=[int(x) for x in input().strip().split(' ')]
    arr=[0,1,1,1,2,2,3,3,4]
    solution=Solution()
    k = solution.removeDuplicates(arr)
    print(arr[:k])







